/**
 * returns encoded url param string of this form {'id':'123f'} -> 'id=123f'
 * @param 		mixed		params
 * @return		string		encParams
 */
function getEncodedParams(params){
	var encParams = '';
	for(var param in params)
		encParams += param + '=' + encodeURIComponent(params[param]) + '&';
	return encParams.substring(0,encParams.length-1);
}


/**
 * checks if obj is null or not
 * @param 		mixed		obj
 * @return		bool		isNull
 */
function isNull(obj){
	// if obj is null return true
	var isNull = true;
	if (obj!=null){
		isNull = false;
		try{
			var type = obj.type;
			switch (type){
			case "checkbox":
			case "radio": // fallthrough wanted!!
				var isChecked = false;
				var elements = document.getElementsByName(obj.id);
				var i=0;
				while (isChecked==false && i < elements.length){
					if (elements[i++].checked)
						isChecked = true;
				}

				isNull = (isChecked ? false : true);
				break;
			case "text":
			case "file":
			case "hidden":
			case "textarea": 
				isNull = (obj.value == '' ? true : false);
				break;
				
			default:
				alert("<isNull>: no definition found for type " + type + "!");
			break;
			}	
		}
		catch (e){
			alert("<isNull>: error while validating element!");
		}
	}
	return isNull;
}